home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / SprocketInvaders / Source / Blitter.c < prev    next >
Encoding:
Text File  |  2000-09-28  |  2.0 KB  |  69 lines  |  [TEXT/CWIE]

  1. //•    ------------------------------------------------------------------------------------------    •
  2. //•
  3. //•    Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  4. //•
  5. //•
  6. //•        You may incorporate this sample code into your applications without
  7. //•        restriction, though the sample code has been provided "AS IS" and the
  8. //•        responsibility for its operation is 100% yours.  However, what you are
  9. //•        not permitted to do is to redistribute the source as "DSC Sample Code"
  10. //•        after having made changes. If you're going to re-distribute the source,
  11. //•        we require that you make it clear in the source that the code was
  12. //•        descended from Apple Sample Code, but that you've made changes.
  13. //•
  14. //•        Authors:
  15. //•            Chris De Salvo
  16. //•
  17. //•    ------------------------------------------------------------------------------------------    •
  18.  
  19. //•    ------------------------------    Includes
  20.  
  21. #include <QDOffscreen.h>
  22. #include <Types.h>
  23.  
  24. #include "Blitter.h"
  25.  
  26. //•    ------------------------------    Private Definitions
  27. //•    ------------------------------    Private Types
  28. //•    ------------------------------    Private Variables
  29. //•    ------------------------------    Private Functions
  30. //•    ------------------------------    Public Variables
  31.  
  32. //•    --------------------    TransBitBlit
  33.  
  34. void
  35. TransBitBlit(UInt8 *image, CGrafPtr dest, UInt32 width, UInt32 height, UInt32 fullWidth, SInt32 x, SInt32 y)
  36. {
  37. UInt32    srcRowBytes, destRowBytes;
  38. UInt8    *srcBits, *destBits;
  39. UInt32    h, v;
  40.  
  41.     srcRowBytes = fullWidth;
  42.     
  43.     //•    Find the base address and rowbytes of the destination buffer
  44.     destRowBytes = (**(*dest).portPixMap).rowBytes & 0x7FFF;
  45.     destBits = (unsigned char *) GetPixBaseAddr(GetGWorldPixMap(dest));
  46.  
  47.     //•    Jump down to the target pixel in the destination
  48.     destBits += y * destRowBytes;
  49.     destBits += x;
  50.     
  51.     srcBits = image;
  52.  
  53.     for (v = 0; v < height; v++)
  54.     {
  55.         for (h = 0; h < width; h++)
  56.         {
  57.             //•    Our transparent color is palette index zero
  58.             if (*srcBits)
  59.                 *destBits = *srcBits;
  60.                 
  61.             destBits++;
  62.             srcBits++;
  63.         }
  64.             
  65.         srcBits += srcRowBytes - width;
  66.         destBits += destRowBytes - width;
  67.     }
  68. }
  69.